<template>
	<view class="" style="background-color: #f8f8f8;">
		<view class="" style="height: 26rpx;">
			
		</view>
		<view class="" style="display: flex;justify-content: space-between;align-items: center;">
			<view style="height: 100%;width: 100%;background-color: #fff;border-radius: 20rpx;padding: 20rpx;">
				<view class="" style="display: flex;justify-content: space-between;border-bottom: 1rpx solid #d5d7da;padding: 20rpx 0;">
					<view class="" style="display: flex;">
						<img src="../../static/img/ream.png" alt="" style="width: 40rpx;height: 40rpx;min-height: 40rpx;min-width: 40rpx;" />
						<view class="" style="margin-left: 30rpx;">
							<view class="" style="font-weight: bold;">
								{{Memorandum.title}}
							</view>
							<view class="" style="font-size: 24rpx;color: #c8c9cd;margin-top: 10rpx;">
								{{Memorandum.remindDate}}
							</view>
						</view>
					</view>
					<view class="" style="margin-left: 6rpx;">
						<image src="../../static/img/yb.png" mode="" style="width: 80rpx;height: 80rpx;" v-if="Memorandum.level == 1"></image>
						<image src="../../static/img/jj.png" mode="" style="width: 80rpx;height: 80rpx;" v-if="Memorandum.level == 2"></image>
						<!-- <image src="../../static/img/jj.png" mode="" style="width: 80rpx;height: 80rpx;"></image> -->
					</view>
				</view>
				<view class="" style="padding: 20rpx;height: 70%;">
					<view class="" style="height: 300rpx;">
						<u-input v-model="Memorandum.content" type="textarea"  auto-height />
						<!-- {{Memorandum.content}} -->
					</view>
					<view class="" style="display: flex;justify-content: center;">

					</view>
				</view>
			</view>
		</view>
		<view class="" style="padding: 0 30rpx;position: absolute;bottom: 100rpx;width: 100%;">
			<u-button type="primary" shape="circle" @click="EditMemoran">已完成</u-button>
			<view class="" style="height: 30rpx	;"></view>
			<u-button shape="circle" @click="show=true">修改优先级</u-button>
		</view>
		<u-select v-model="show" :list="list" @confirm="confirm"></u-select>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:'',
				show: false,
				Memorandum:{},
				list: [
					{
						value: '1',
						label: '一般'
					},
					{
						value: '2',
						label: '紧急'
					}
				],
			}
		},
		onLoad(option) {
			this.id = option.id
			console.log(this.id)
			this.getMemorandum()
		},
		methods: {
			async EditMemoran(){
				const res = await this.$api.EditMemorandum({'id':this.id,'content':this.Memorandum.content})
				console.log(res)
				if(res.code==1){
					this.getMemorandum()
					this.$refs.uToast.show({
						title: res.msg,
						type: 'success'
					})
				}else{
					this.$refs.uToast.show({
						title: res.msg,
						type: 'error'
					})
				}
			},
			confirm(e) {
				console.log(e);
				this.Memorandum.level = e[0].value
				this.editLevel()
			},
			async editLevel(){
				console.log(this.Memorandum)
				const res = await this.$api.EditMemorandum({'id':this.id,'level':this.Memorandum.level})
				console.log(res)
				if(res.code==1){
					this.getMemorandum()
					this.$refs.uToast.show({
						title: res.msg,
						type: 'success'
					})
				}else{
					this.$refs.uToast.show({
						title: res.msg,
						type: 'error'
					})
				}
			},
			async getMemorandum(){
				const res = await this.$api.MemorandumDetail({'id':this.id})
				console.log(res)
				if(res.code==1){
					this.Memorandum = res.data
				}else{
					this.$refs.uToast.show({
						title: res.msg,
						type: 'error'
					})
				}
			},
			onPageScroll(e) {
				this.scrollTop = e.scrollTop;
			},
			toAdd(){
				uni.navigateTo({
					url:'/pages/memorandum/add'
				})
			},
			
			toDetail(item){
				uni.navigateTo({
					url:'/pages/memorandum/memorandumDetail?id='+item.id
				})
			}
		}
		
	}
</script>

<style>
</style>